package cn.flant.task.console;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Command {
	private String name;
	private Map<String, String> options = new HashMap<String, String>();
	private CommandContext context = null;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean containsOption(String... opts) {
		boolean result = true;
		for (String opt : opts) {
			if (options.containsKey(opt)) {
				continue;
			} else {
				result = false;
				break;
			}
		}
		return result;
	}

	public void putOptionValue(String option) {
		putOptionValue(option, null);
	}

	public void putOptionValue(String opt, String value) {
		options.put(opt, value);
	}

	public String getOptionValue(String opt) {
		return getOptionValue(opt, null);
	}

	public String getOptionValue(String opt, String def) {
		String value = options.get(opt);
		if (value == null) {
			value = def;
		}
		return value;
	}

	public Set<String> getOptionSet() {
		return options.keySet();
	}

	public CommandContext getContext() {
		return context;
	}

	public void setContext(CommandContext context) {
		this.context = context;
	}

}